#!/bin/bash
# Copyright (c) 2023 Chengxuya.
# This is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#
#          http://license.coscl.org.cn/MulanPSL2
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.

readonly PLUGINS_PATH="$HOME/.oh-my-zsh/custom/plugins"

if [ ! -e "$PLUGINS_PATH" ]; then
    echo -e "\033[1;33mplease install zsh\033[0m"
    exit 1
fi

cd "$HOME/.oh-my-zsh/custom/plugins"
if [ ! -e "$PLUGINS_PATH/zsh-syntax-highlighting" ]; then
    git clone https://gitee.com/doublebyte/zsh-syntax-highlighting.git
    if [ $? -ne 0 ]; then
        echo -e "\033[1;33mclone zsh-syntax-highlighting failed\033[0m"
        exit 1
    fi
fi
if [ ! -e "$PLUGINS_PATH/zsh-autosuggestions" ]; then
    git clone https://gitee.com/doublebyte/zsh-autosuggestions.git
    if [ $? -ne 0 ]; then
        echo -e "\033[1;33mclone zsh-autosuggestions failed\033[0m"
        exit 1
    fi
fi
